<template>
  <van-popup
      :value="visible"
      title=""
      position="bottom"
      @click-overlay="$emit('update:visible', false);"
  >
    <ul>
      <li v-for="item in list" :class="{selected:selected == item }" @click="select(item)">
        <img v-if="selected === item" src="../assets/img/icon_select.png" alt=""/>
        {{item |token_type}}
      </li>
    </ul>
  </van-popup>
</template>

<script lang="ts">
    import {Component, Vue, Prop} from 'vue-property-decorator';

    @Component
    export default class TypeSelect extends Vue {
        private list: Array<any> = [0, 1, 2];
        private selected: any = null;

        @Prop({
            type: Boolean,
            default: false
        }) visible: Boolean = false;

        @Prop({
            type: Number,
            default: ""
        }) value: any;


        select(item: any): void {
            this.selected = item;
            this.$emit('input', item);
            this.$emit('confirm', item)
        }
    }
</script>

<style scoped lang="scss">
  ul {
    background-color: #333649;
    color: #ffffff;
    border-radius: 20px 20px 0 0;
    max-height: 200px;
    overflow-y: auto;

    li {
      position: relative;
      display: flex;
      justify-content: center;
      align-items: center;
      height: 70px;
      font-size: 18px;

      &:after {
        @include onePxBottom;
      }

      img {
        margin-right: 12px;
        width: 24px;
        height: 24px;
      }
    }
  }

  .selected {
    color: #F29049;
  }
</style>